package com.siyu.basedata.pptnrlaste.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.siyu.common.core.controller.BaseController;
import com.siyu.common.core.domain.AjaxResult;
import com.siyu.common.core.page.TableDataInfo;
import com.siyu.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.siyu.basedata.pptnrlaste.domain.PptnRLaste;
import com.siyu.basedata.pptnrlaste.service.IPptnRLasteService;

/**
 * 雨量历史数据Controller
 *
 * @author hrhy
 * @date 2024-06-20
 */
@RestController
@RequestMapping("/basedata/pptnrlaste")
public class PptnRLasteController extends BaseController {
    @Autowired
    private IPptnRLasteService pptnRLasteService;

    /**
     * 查询雨量历史数据列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PptnRLaste pptnRLaste) {
        startPage();
        List<PptnRLaste> list = pptnRLasteService.selectPptnRLasteList(pptnRLaste);
        return getDataTable(list);
    }

    /**
     * 导出雨量历史数据列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, PptnRLaste pptnRLaste) {
        List<PptnRLaste> list = pptnRLasteService.selectPptnRLasteList(pptnRLaste);
        ExcelUtil<PptnRLaste> util = new ExcelUtil<PptnRLaste>(PptnRLaste.class);
        util.exportExcel(response, list, "雨量历史数据数据");
    }

    /**
     * 获取雨量历史数据详细信息
     */
    @GetMapping(value = "/{stcd}")
    public AjaxResult getInfo(@PathVariable("stcd") String stcd) {
        return success(pptnRLasteService.selectPptnRLasteByStcd(stcd));
    }

    /**
     * 新增雨量历史数据
     */
    @PostMapping
    public AjaxResult add(@RequestBody PptnRLaste pptnRLaste) {
        return toAjax(pptnRLasteService.insertPptnRLaste(pptnRLaste));
    }

    /**
     * 修改雨量历史数据
     */
    @PutMapping
    public AjaxResult edit(@RequestBody PptnRLaste pptnRLaste) {
        return toAjax(pptnRLasteService.updatePptnRLaste(pptnRLaste));
    }

    /**
     * 删除雨量历史数据
     */
    @DeleteMapping("/{stcds}")
    public AjaxResult remove(@PathVariable String[] stcds) {
        return toAjax(pptnRLasteService.deletePptnRLasteByStcds(stcds));
    }
}
